#include <func.h>

int main(int argc,char *argv[])
{
    int fdw=open(argv[1],O_WRONLY);//1号管道写端
    ERROR_CHECK(fdw,-1,"open");
    int fdr=open(argv[2],O_RDONLY);//读端
    ERROR_CHECK(fdr,-1,"open");
    printf("fdr=%d,fdw=%d 开始通信\n",fdr,fdw);
    char buf[1000];
    while(1)
    {
        //先读管道
        memset(buf,0,sizeof(buf));
        read(fdr,buf,sizeof(buf));//读2号管道
        printf("%s",buf);
        memset(buf,0,sizeof(buf));
        //读标准输入
        read(STDIN_FILENO,buf,sizeof(buf));
        //发送给对方,写1号管道
        write(fdw,buf,strlen(buf));
    }
    return 0;
}